#! /usr/bin/python

import sys, os
           
scriptpath = os.path.dirname(sys.argv[0])        
project_home = os.path.abspath(os.path.join(scriptpath, os.pardir))

def main():
    with open('{}/design/files.lst'.format(project_home), 'r') as reader:
        newline = "read_verilog -sv { \\\n"
        for line in reader.readlines():
            line = line.replace("\n", "")
            newline += "       " + line + ' \\\n'
        newline += "  }"

        with open('{}/scripts/add_labcore.tcl'.format(project_home), 'w') as writer:
            writer.writelines(newline)

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    main()

